<template>
	<view class="popup">
		<!-- 遮罩层 -->
		<view class="mask" @click="_close" @touchmove.stop.prevent="moveHandle"></view>
		
		<view class="popup-content">
			<view class="popTitle" v-if="popUpTitle">
				{{ popUpTitle }}
			</view>
			
			<view class="popContent">
				{{ popUpContent.mobile }}
			</view>
			
			<view class="popBtn">
				<view class="pop_btn" style="color: #7B7A8D;" @click="btnClick('0')">取消</view>
				<!-- <view class="pop_btn" @click="btnClick('1')">已沟通</view> -->
				<view class="pop_btn" @click="btnClick('2')">{{ showType=='phone'?'拨打':'发短信' }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			isPopup: {
				type: Boolean,
				default(){
				    return false
				}
			}, 
			popUpTitle: {
				type: String,
				default() {
					return ''
				}
			},
			popUpContent: {
				type: Object,
				
	
			}, 
			popUpBtn: {
				type: String,
				default() {
					return '确定'
				}
			},
			//phone sms
			showType:{
				type:String,
				
			}
		},
		data(){
			return{
				
			}
		},
		watch: {
			isPopup(newVal) {
				this.isPopup = newVal
			},
			
			popUpContent(newVal){

				this.popUpContent = newVal
			},
			showType(newVal){
				this.showType = newVal
			},
			popUpTitle(newVal){
				this.popUpTitle = newVal
			},
		},
		mounted(){
			// console.log(this.popUpContent,"popUpContentpopUpContentpopUpContentpopUpContentpopUpContentpopUpContent")
		},
		methods: {
			_close() {
				// this.isPopup = false
				this.$emit('update:showModalOperation', false)
			},
			btnClick(flag) {
				console.log(flag)
				// this.isPopup = false
				
				switch (flag){
					case '0':
					this.$emit('update:showModalOperation', false)
						break;
					case '1':
						if(this.showType=='phone'){
							if(this.popUpContent.isEdit){
						
								uni.navigateTo({
									// id 跟进id, uniqueId 唯一id, followUp 形式, followNum 跟进次数,followPurposes 目的
									url: `/pages/clue/clueFollowUp/index?id=${this.popUpContent.id}&uniqueId=${this.popUpContent.uniqueId}&followNum=${this.popUpContent.followNum || 0}&followUp=phone&phone=${this.popUpContent.mobile}&clueStatus=${this.popUpContent.clueStatus || ''}`
								})
							} else {
								uni.redirectTo({
									// id 跟进id, uniqueId 唯一id, followUp 形式, followNum 跟进次数,followPurposes 目的
									url: `/pages/clue/clueFollowUp/index?uniqueId=${this.popUpContent.uniqueId}&followNum=${this.popUpContent.followNum || 0}&followUp=phone&phone=${this.popUpContent.mobile}&clueStatus=${this.popUpContent.clueStatus || ''}`
								})
							}
							
						}else if(this.showType=='sms'){
							console.log()
							if(this.popUpContent.isEdit){
								uni.navigateTo({
									// id 跟进id, uniqueId 唯一id, followUp 形式, followNum 跟进次数,followPurposes 目的
									url: `/pages/clue/clueFollowUp/index?id=${this.popUpContent.id}&uniqueId=${this.popUpContent.uniqueId}&followNum=${this.popUpContent.followNum || 0}&followUp=sms&phone=${this.popUpContent.mobile}&clueStatus=${this.popUpContent.clueStatus || ''}`
								})
							} else {
								uni.redirectTo({
									// id 跟进id, uniqueId 唯一id, followUp 形式, followNum 跟进次数,followPurposes 目的
									url: `/pages/clue/clueFollowUp/index?uniqueId=${this.popUpContent.uniqueId}&followNum=${this.popUpContent.followNum || 0}&followUp=sms&phone=${this.popUpContent.mobile}&clueStatus=${this.popUpContent.clueStatus || 0}`
								})
							}
						}
						this.$emit('update:showModalOperation', false)
						break;
					case '2':
						if(this.showType=='phone'){
							uni.makePhoneCall({
								phoneNumber: this.popUpContent.mobile
							});
						}else if(this.showType=='sms'){
							// #ifdef APP-PLUS
							var msg = plus.messaging.createMessage(plus.messaging.TYPE_SMS);
							msg.to = [this.popUpContent.mobile];
							msg.body = '';
							plus.messaging.sendMessage(msg);
							// #endif
						}
						this.$emit('update:showModalOperation', false)
						break;
				}
			},
			moveHandle() {},
		}
	}
</script>

<style lang="scss" scoped>
	.popup {
		width: 100%;
		position: relative;
		
		.mask{
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			background-color: rgba(0, 0, 0, .5);
			z-index: 1000;
		}
		
		.popup-content {
			width: 550rpx;
			background: #fff;
			border-radius: 8rpx;
			box-sizing: border-box;
			position: fixed;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
			z-index: 9999;
			
			.popTitle {
				width: 100%;
				text-align: center;
				font-size: 28rpx;
				font-weight: bold;
				color: #43425D;
				margin-bottom: 40rpx;
				padding-top: 30rpx;
			}
			
			.popContent {
				font-size: 28rpx;
				font-weight: 400;
				line-height: 42rpx;
				color: #43425D;
				text-align: center;
				padding: 30rpx 0;
			}
			
			.popBtn {
				width: 100%;
				display: flex;
				border-top: 2rpx solid #F5F6FA;
				
				.pop_btn {
					flex: 1;
					text-align: center;
					border-right: 2rpx solid #F5F6FA;
					padding: 20rpx 0;
					color: #3B86FF;
					
					&:last-child {
						border-right: none;
					}
				}
			}
		}
	}
</style>
